package com.hui.service;

import com.hui.dao.MenuDao;
import com.hui.entity.Menu;
import com.hui.util.MenuUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @Description Menu业务层
 */
public class MenuService {

    public List<Menu> findMenuById(int marId) {
        MenuDao dao = new MenuDao();
        List<Menu> list = dao.findMenuById(marId);

        return MenuUtil.conversionList(list);
    }


    public Map<String, List<Menu>> getAllMenu() {
        MenuDao dao = new MenuDao();

        Map<String, List<Menu>> map = new HashMap<>();

        List<Menu> list1 = dao.findByMenuLevel(1);
        List<Menu> list2 = dao.findByMenuLevel(2);


        map.put("list1", list1);
        map.put("list2", list2);

        return map;
    }

    public List<Menu> getChildMenu(String code) {
        MenuDao dao = new MenuDao();
        List<Menu> list = dao.findByMenuCode(code);

        return list;
    }

    public void changeMenuState(int menuId, String menuState) {

        MenuDao dao = new MenuDao();
        dao.UpdateByMenuState(menuId, menuState);

    }


    public List<Menu> findMenuAll() {
        MenuDao dao = new MenuDao();
        List<Menu> list = dao.findMenuAll();
        return MenuUtil.conversionList(list);
    }





}
